import { defHttp } from '/@/utils/http/axios';
import {
  getMenuListResultModel,
  MenuListGetResultModel,
  MenuParams,
  CreatePermissionParam,
  UpdatePermissionParam,
} from './model/menuModel';
enum Api {
  GetMenuList = '/system/users/getMenuList',
  GetAllMenuList = '/system/users/getAllMenuList',
  MenuList = '/system/permission/getPermList',
  CreatePermission = '/system/permission/createPermission',
  UpdatePermission = '/system/permission/updatePermission',
  IsPermissionExist = '/system/permission/isPermissionExist',
  DeletePermission = '/system/permission/deletePermission',
}

/**
 * @description: Get user menu based on id
 */

export const getMenuList = () => {
  return defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList });
};

export const deletePermission = (permissionId: number) =>
  defHttp.get({ url: Api.DeletePermission, params: { permissionId } });

export const isPermissionExist = (permissionName: string) =>
  defHttp.get({ url: Api.IsPermissionExist, params: { permissionName } });

export const getAllMenuList = () => {
  return defHttp.get<getMenuListResultModel>({ url: Api.GetAllMenuList });
};

export const queryMenuList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });

export const createPermission = (params?: CreatePermissionParam) =>
  defHttp.post({ url: Api.CreatePermission, params: params });

export const updatePermission = (params?: UpdatePermissionParam) =>
  defHttp.post({ url: Api.UpdatePermission, params: params });
